package devices

import (
	"api/internal/respons"
	"api/internal/svc"
	"api/internal/types"
	"context"
	"device_srv/deviceclient"

	"github.com/zeromicro/go-zero/core/logx"
)

// @Summary 设备信息详情
// @Description 查询一个设备信息
// @Tags 查询
// @Accept json
// @Produce json
// @Param data body types.SendSmsReques true "data"
// @Success 200 {object} types.Response
// @Failure 400 {string} types.Response
// @Failure 500 {string} types.Response
// @Router /devices/devicesDelete [get]
type DevicesDetailLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDevicesDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DevicesDetailLogic {
	return &DevicesDetailLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// DevicesDetail 设备信息详情
func (l *DevicesDetailLogic) DevicesDetail(req *types.DevicesDetailRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	detail, err := l.svcCtx.DeviceRpc.DevicesDetail(l.ctx, &deviceclient.DevicesDetailRequest{
		Id: req.Id,
	})
	if err != nil {
		return respons.Error(400, "获取设备详情失败", nil), err
	}

	return respons.Success(detail), nil
}
